﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Android2Unity : MonoBehaviour
{
    [SerializeField] private Text mText;

    [SerializeField] private Text mText2;

    [SerializeField] private Button mBtn;
    void Start()
    {
        mBtn.onClick.AddListener(BtnClick);
    }

    void BtnClick()
    {
        //var javeObject = new AndroidJavaObject("com.fch.loadlib.MainActivity");
        //string returnString = javeObject.Call<string>("CallAndroidMessage", "ben");
        //mText2.text = returnString;

        DownloadHelper help = new DownloadHelper();

        help.Download("//192.168.21.200/CreatPart/Install","CreatPart.apk");

        help.SetDownloadListener(new DownLoadListener()); 
    }


    class DownLoadListener : DownloadHelper.IDownloadListener
    {
        public void OnDownloaded(string name)
        {
            Debug.Log("OnDownloaded:"+name);
        }

        public void OnError(string name, string message)
        {
            Debug.Log("OnError:"+name + " | "+message);
        }

        public void OnProgress(string name, int progress)
        {
            Debug.Log("OnProgress:"+name +" | "+progress.ToString());
        }
    }


    //安卓返回显示的信息
    public void ShowMessage(string message)
    {
        mText.text = message;
    }

}
